1. Field of the Invention
The present invention relates to techniques for improving computer system performance. More specifically, the present invention relates to a method and an apparatus for selectively executing differently optimized versions of executable code, which are generated from the same source code, wherein the different versions of the executable code are optimized for different runtime conditions and/or different system configurations.
2. Related Art
In order to improve the performance of computer applications, the executable code for an application is often optimized for a specific processor type. However, users often need to migrate an application to a new system which may have a different processor type than the one that was used to optimize the application. Nevertheless, users expect their existing executable codes not only to run, but to run well on a new system. Unfortunately, many of the current optimization techniques that improve performance for a specific processor type can degrade performance for other processor types.
This problem becomes more complicated for systems equipped with multi-core processors. In such systems, even if an application is executed on the processor of the type it was optimized for, good performance may not be achieved because it is impossible for the compiler to anticipate how heavily utilized the cores will be at runtime. For example, if the compiler optimizes the application by employing aggressive speculation and the cores are heavily utilized at runtime, the aggressive speculation may excessively consume highly contended processor resources, thereby degrading the performance of the application as well as the performance of other applications running on the same cores.
Another commonly encountered problem that can severely degrade performance is caused by processor temperature increases during execution. Typically, when the processor/core temperature exceeds a specific limit, the processor will either decrease its clock-frequency, or will temporarily disable one or more of its cores. Unfortunately, either reducing the clock-frequency or temporarily disabling one or more cores can lead to unacceptable performance degradation.
In all of the above scenarios, optimal performance of the application cannot be achieved because the associated executable code was optimized for conditions and/or system configurations which are different from the actual runtime conditions and/or system configurations.
Hence, what is needed is a method and an apparatus for achieving optimized performance while executing an application under different operating conditions and on different systems without the above-described problems.